/*! \file SourceBinaire.hpp
    \brief Une interface permettant de manipuler plusieurs types de sources binaire via la meme abstraction. 
*/

#ifndef __SOURCE_BINAIRE__
#define __SOURCE_BINAIRE__

/*
  Pour construire des sources binaires variées 
  il suffit de dériver cette classe et implémenter la méthode 
  getRandomBit
*/

/**
 * \class SourceBinaire 
 * \brief Interface permettant des sources binaires
 */
class SourceBinaire
{
  
public:
  SourceBinaire(){}
  
  virtual ~SourceBinaire(){}
  
  virtual int getRandomBit()
  {
    //std::cout << "ss"<<std::endl;
    return 0;
  }
};




/**
 *Une source aléatoire de bernouillie
 */
#include <boost/random/bernoulli_distribution.hpp>

/*BOOST*/
#include <boost/random/linear_congruential.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/random/bernoulli_distribution.hpp>


/**
 * \class Bernouillie 
 * \brief Interface permettant des sources binaires
 */
class Bernouillie:public SourceBinaire
{
  
  
  typedef boost::bernoulli_distribution<> distribution_bernouillie;
  typedef boost::minstd_rand base_generator_type;
  
  
private:
  float param;
  distribution_bernouillie *bern;
  base_generator_type * generateur;
  
public:
  
  Bernouillie(float p):SourceBinaire()
  {
    this->param=p;
    this->bern =new distribution_bernouillie(p);
    this->generateur=new base_generator_type(std::time(0));
  }
  
  ~Bernouillie()
  {
    delete this->bern;
    delete this->generateur;
  }
  virtual int getRandomBit()
  {
    int val = bern->operator()(*generateur);
    #ifdef DEBUG
    std::cout << "Valeur Bernou: " <<val<<std::endl;
    #endif
    return val;
  }
};

#endif
